<template>
	<!-- 开屏广告 -->
	<view class="init">
		<view class="initBox" >
			<view  class="myVideoBox">
				<video @loadedmetadata="loadedmetadata"  id="myVideo" class="myVideo" :src="screenShow" :controls="false" :autoplay="true"></video>
				<view @click="tiao" class="tiao">跳过 {{tiaoTime}}</view>
			</view>
			<view  class="myVideoTop">
				<image src="https://z3.ax1x.com/2021/09/26/4ckYHP.png" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				screenShow: null,
				videoContext: null,
				tiaoTime:3,
				Time: null
			}
		},
		onLoad(params) {
			this.screenShow = params.screenShow;
		},
		methods:{
			tiao(){
				clearInterval(this.Time);
				this.init();
			},
			loadedmetadata(event){
				this.tiaoTime = Math.ceil(event.detail.duration);
				this.Time = setInterval(()=>{
					this.tiaoTime--;
					if(this.tiaoTime == 0){
						this.tiaoTime = "";
					    clearInterval(this.Time);
						this.init();
					}
				},1000)
			},
			init() {
				this.$apis.accountInfo().then(res => {
					if(res.code == 200){
						// 判断用户是否需要邀请码
						// debugger
						if (res.data.needInviteCode) {
							console.log(res.data.inviteCode)
							// debugger
							if(res.data.inviteCode){
								
								uni.switchTab({
									url: "../index/index"
								})
							}else{
							
								// debugger
								uni.navigateTo({
									url: "../invite/invite"
								})
							}
						} else {
							// debugger
							uni.switchTab({
								url: "../index/index"
							})
						}
					
					
					}else if(res.data == 500){
						uni.clearStorageSync();
					}
					
					console.log("个人信息成功", res)
				})
			},
			
			
		}
	}
</script>

<style lang="scss">
	
	.init{
		width: 750rpx;
		height: 100vh;
		background: #ffffff;
	}
	.initBox{
		width: 100%;
		height: 100vh;
	}
	.myVideoBox{
		  width: 100%;
		  height: calc(100vh - 250rpx);
		  position: relative;
	}
	.myVideoTop{
		width: 100%;
		height: 260rpx;
		background-color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		image{
			width: 375rpx;
		}
	}
	.tiao{
		width: 190rpx;
		height: 88rpx;
		line-height: 88rpx;
		opacity: 1;
		background:rgba(0,0,0,.6);
		border-radius: 48rpx;
		font-size: 32rpx;
		font-family: Source Han Sans CN, Source Han Sans CN-Regular;
		font-weight: 400;
		text-align: CENTER;
		color: #ffffff;
		position: absolute;
		bottom: 30rpx;
		right: 20rpx;
		z-index: 9;
	}
	.myVideo{
		width: 100% !important;
		height: 100% !important;
	}
	.init_image{
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
	}
	.init_image image{
		width: 750rpx;
	}
</style>
